package com.qingmi.farmer.data.repository.api;

import com.qingmi.farmer.data.model.Banner;
import com.qingmi.farmer.data.model.HomeData;
import com.qingmi.farmer.data.model.News;
import com.qingmi.farmer.data.model.Notice;
import com.wjjun.base.data.net.HTTPSService;
import com.wjjun.base.data.preference.UserPreference;
import com.qingmi.farmer.data.request.GetNewsListReq;
import com.qingmi.farmer.data.request.GetNoticesReq;
import com.wjjun.basemvpvm.data.net.HttpApiManager;
import com.wjjun.basemvpvm.data.net.filter.BaseResponseFilter;
import com.wjjun.basemvpvm.data.repository.BaseApiRepository;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * 首页/其他模块
 * Created by 67535 on 2018/5/23.
 */
public class OtherApiRepository extends BaseApiRepository {

    private UserPreference userPreference;

    @Inject
    public OtherApiRepository(HttpApiManager httpApiManager, BaseResponseFilter filter, UserPreference userPreference) {
        super(httpApiManager, filter);
        this.userPreference = userPreference;
    }

    /**
     * 获取首页数据
     */
    public Observable<HomeData> getHomeData() {
        return res2Entity(httpApiManager.getService(HTTPSService.class).getHomeData());
    }

    /**
     * 获取banner
     */
    public Observable<List<Banner>> getBanner() {
        return res2Entity(httpApiManager.getService(HTTPSService.class).getBanner());
    }


    /**
     * 获取多个新闻
     */
    public Observable<List<News>> getNewsList(GetNewsListReq req) {
        return res2Entity(httpApiManager.getService(HTTPSService.class).getNewsList(req.toMap()));
    }

    /**
     * 获取多个公告
     */

    public Observable<List<Notice>> getNotices(GetNoticesReq req) {
        return res2Entity(httpApiManager.getService(HTTPSService.class).getNotices(req.toMap()));
    }


}

